//
//  DetailViewController.swift
//  MathMonsters
//
//  Created by cygarm on 15/8/15.
//  Copyright (c) 2015年 cygarm. All rights reserved.
//

import UIKit

class DetailViewController: UIViewController {
	@IBOutlet weak var nameLabel: UILabel!
	@IBOutlet weak var descriptionLabel: UILabel!
	@IBOutlet weak var iconImageView: UIImageView!
	@IBOutlet weak var weaponImageView: UIImageView!
	
	var monster: Monster! {
		didSet (newMonster) {
			self.refreshUI()
		}
	}
	
	func refreshUI() {
		nameLabel?.text = monster.name
		descriptionLabel?.text = monster.description
		iconImageView?.image = UIImage(named: monster.iconName)
		weaponImageView?.image = monster.weaponImage()
	}

	override func viewDidLoad() {
		super.viewDidLoad()

		// Do any additional setup after loading the view.
		refreshUI()
	}

	override func didReceiveMemoryWarning() {
		super.didReceiveMemoryWarning()
		// Dispose of any resources that can be recreated.
	}
	

	// MARK: - Navigation

	// In a storyboard-based application, you will often want to do a little preparation before navigation
//	override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
//			// Get the new view controller using segue.destinationViewController.
//			// Pass the selected object to the new view controller.
//	}

}

extension	DetailViewController: MonsterSelectionDelegate {
	func monsterSelected(newMonster: Monster) {
		monster = newMonster
	}
}
